package com.tinyspot.concrete.starter.business;

import com.tinyspot.concrete.starter.business.processor.CompanyProcessor;
import com.tinyspot.concrete.starter.business.processor.OrderCheckProcessor;
import com.tinyspot.concrete.starter.business.processor.OrderQueryProcessor;
import com.tinyspot.concrete.starter.business.processor.UserProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Tinyspot
 * @date 2023-01-07 22:37
 */
@Configuration
public class CommonBizProcessorConfig {

    @Resource
    private OrderQueryProcessor orderQueryProcessor;
    @Resource
    private OrderCheckProcessor orderCheckProcessor;
    @Resource
    private UserProcessor userProcessor;
    @Resource
    private CompanyProcessor companyProcessor;

    @Bean
    public CommonBizProcessor orderCommonProcessor() {
        CommonBizProcessor commonProcessor = new CommonBizProcessor();
        List<IProcessor> processorList = new ArrayList<>();
        processorList.add(orderCheckProcessor);
        processorList.add(orderQueryProcessor);
        processorList.add(userProcessor);
        commonProcessor.setProcessorList(processorList);
        return commonProcessor;
    }

    @Bean
    public CommonBizProcessor userCommonProcessor() {
        CommonBizProcessor commonProcessor = new CommonBizProcessor();
        List<IProcessor> processorList = new ArrayList<>();
        processorList.add(userProcessor);
        processorList.add(companyProcessor);
        commonProcessor.setProcessorList(processorList);
        return commonProcessor;
    }
}
